@import '../../styles/var.less';

.k-color-picker {
  // width: 55px;
  height: 32px;
  border: 1px solid var(--kui-color-border);
  border-radius: var(--kui-border-radius);
  position: relative;
  display: inline-flex;
  box-sizing: border-box;
  align-items: center;
  padding: 3px;

  &:hover,
  &:focus {
    border-color: var(--kui-color-main-hover);
  }

  &:active {
    opacity: .8;
  }

  .k-color-picker-selection {
    line-height: 1.571;
    display: flex;
    align-items: center;
    // padding: 2px;
    cursor: pointer;
  }

  .k-color-picker-color {
    height: 24px;
    width: 24px;
    border-radius: 12%;
    // margin: 2px;
    overflow: hidden;
    background-image: linear-gradient(-45deg, #cdcdcd 25%, transparent 0), linear-gradient(45deg, #cdcdcd 25%, transparent 0), linear-gradient(-45deg, transparent 75%, #cdcdcd 0), linear-gradient(45deg, transparent 75%, #cdcdcd 0);
    background-size: 50% 50%;
    background-position: 0 0, 0 -5.5px, -5.5px 5.5px, 5.5px 0;
    box-shadow: inset 0 0 1px 0 rgba(255, 255, 255, 0.25);

    .k-color-picker-color-inner {
      height: 100%;
      width: 100%;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
      border-radius: inherit;
    }
  }

  .k-color-picker-arrow {
    margin: 0 5px;
    font-size: 16px;
    color: var(--kui-color-icon);
    transition: transform .3s cubic-bezier(0.075, 0.82, 0.165, 1);
  }

  .k-color-picker-trigger-text {
    font-size: 14px;
    margin-left: 8px;
    margin-right: 4px;
  }
}


.k-color-picker-opened {
  border: 1px solid var(--kui-color-main);
  box-shadow: 0 0 0 2px var(--kui-color-main-90);

  .k-color-picker-arrow {
    transform: rotate(180deg);
  }
}

.k-color-picker-disabled {
  cursor: not-allowed;
  background: var(--kui-color-disable-back);
  border-color: var(--kui-color-disable-border);

  * {
    cursor: not-allowed;
  }

  .k-color-picker-color {
    opacity: .5;
  }

  &:hover {
    border-color: var(--kui-color-disable-border);
  }

  &:active {
    opacity: 1;
  }
}

.k-color-picker-lg {
  // width: 70px;
  height: 40px;

  .k-color-picker-color {
    width: 32px;
    height: 32px;
  }

  .k-color-picker-arrow {
    font-size: 22px;
  }

  .k-color-picker-trigger-text {
    font-size: 16px;
  }
}

.k-color-picker-sm {
  // width: 45px;
  height: 22px;
  padding: 2px;

  .k-color-picker-color {
    width: 16px;
    height: 16px;
    border-radius: 24%;
  }

  .k-color-picker-arrow {
    font-size: 14px;
  }

  .k-color-picker-trigger-text {
    font-size: 12px;
  }

}

.k-color-picker-dropdown {
  width: 254px;
  font-size: 0;
  position: absolute;
  z-index: 1001;


  .k-color-picker-paint-dot {
    width: 15px;
    height: 15px;
    display: block;
    position: absolute;
    box-sizing: border-box;
    // background: var(--kui-color-back);
    // border: 2px solid #fff;
    border: 2px solid var(--kui-color-back);
    box-shadow: 0 0 0 px rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    top: 10px;
    left: 10px;
    pointer-events: none;
  }

  .k-color-picker-paint {
    width: 234px;
    height: 136px;
    border-radius: @radius;
  }

  .k-color-picker-bar {
    padding: 10px 0 0 0;
    display: flex;
  }

  .k-color-picker-avatar {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    float: left;
    background-image: linear-gradient(-45deg, #cdcdcd 25%, transparent 0), linear-gradient(45deg, #cdcdcd 25%, transparent 0), linear-gradient(-45deg, transparent 75%, #cdcdcd 0), linear-gradient(45deg, transparent 75%, #cdcdcd 0);
    background-size: 11px 11px;
    background-position: 0 0, 0 -5.5px, -5.5px 5.5px, 5.5px 0;
    box-shadow: inset 0 0 1px 0 rgba(255, 255, 255, 0.25);

    .k-color-picker-avatar-inner {
      border-radius: 6px;
      width: 100%;
      height: 100%;
      // border: 1px solid var(--kui-color-border);
      box-sizing: border-box;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
    }
  }

  .k-color-picker-bar-box {
    margin-left: 14px;
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    canvas {
      height: 8px;
      width: 190px;
      border-radius: 4px;
    }

    .k-color-picker-alpha {
      background-image: linear-gradient(-45deg, #cdcdcd 25%, transparent 0), linear-gradient(45deg, #cdcdcd 25%, transparent 0), linear-gradient(-45deg, transparent 75%, #cdcdcd 0), linear-gradient(45deg, transparent 75%, #cdcdcd 0);
      background-size: 7px 7px;
      background-position: 0 0, 0 -4px, -4px 4px, 4px 0;
      border: 1px solid #a1a1a1;
      box-sizing: border-box;
    }

    span {
      width: 12px;
      height: 12px;
      display: block;
      position: absolute;
      border: 2px solid var(--kui-color-back);
      box-shadow: 0 0 0 1px rgb(0 0 0 / 7%);
      border-radius: 50%;
      pointer-events: none;
      box-sizing: border-box;
    }

    .k-color-picker-hue-dot {
      top: -2px;
    }

    .k-color-picker-alpha-dot {
      top: 18px;
    }
  }

  .k-color-picker-mode {
    position: relative;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 4px;

    .k-color-picker-key {
      text-align: center;
      font-size: 12px;
      line-height: 1;
      width: 195px;
    }

    .k-select {
      min-width: 0;
      padding: 0;

      .k-select-arrow {
        margin: 0;
      }
    }
  }

  .k-color-picker-mode-label {
    font-size: 12px;
  }

  .k-color-picker-val {
    display: flex;
    gap: 4px;
    flex: 1;
    min-width: 0;
    justify-content: space-around;

    .k-input-number {
      // flex: 0 0 44px;
    }

    .k-color-picker-alpha-input {
      max-width: 45px;
      flex-shrink: 0;
      gap: 2px;
    }
  }

  .k-color-picker-presets {
    position: relative;
    box-sizing: border-box;
    padding: 10px 0 0 0px;
    margin-top: 10px;
    border-top: 1px solid var(--kui-color-border);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;

    >span {
      display: inline-block;
      width: 20px;
      height: 20px;
      border-radius: 2px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;

      &:hover {
        transform: scale(1.3);
      }

      .k-icon {
        color: #fff;
        font-size: 14px;
      }
    }

    .k-btn {
      position: absolute;
      top: 14px;
      right: 0;
      width: 32px;
      padding: 0;
    }
  }

  .k-color-picker-slider-hue {
    position: relative;
  }

  .k-color-picker-arrow {
    position: absolute;
    box-sizing: border-box;
    display: flex;
    width: 24px;
    height: 9px;
    color: var(--kui-color-back);
  }

  .k-color-picker-body {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-radius: var(--kui-border-radius);
    background: var(--kui-color-back);
    border: 1px solid var(--kui-color-gray-80);
    padding: 10px;
    box-sizing: border-box;
  }

  .k-color-picker-paint-container {
    position: relative;
  }

  #ot {
    stroke-width: 1px;
    stroke: var(--kui-color-border);
  }

  &[k-placement^=top] {
    .k-color-picker-body {
      margin-bottom: 10px;
    }

    .k-color-picker-arrow {
      bottom: 4px;
      height: 9px;
    }
  }


  &[k-placement^=bottom] {
    .k-color-picker-body {
      margin-top: 10px;
    }

    .k-color-picker-arrow {
      top: 4px;
      height: 9px;
      transform: rotate(180deg);
    }
  }

  &[k-placement=bottom-left],
  &[k-placement=top-left] {
    .k-color-picker-arrow {
      left: 6px;
    }
  }

  &[k-placement=bottom-right],
  &[k-placement=top-right] {
    .k-color-picker-arrow {
      right: 6px;
    }
  }

  &[k-placement=bottom]{
    .k-color-picker-arrow {
      left: 50%;
      transform: translateX(-50%) rotate(180deg);
    }
  }
  &[k-placement=top] {
    .k-color-picker-arrow {
      left: 50%;
      transform: translateX(-50%);
    }
  }
}

.k-color-picker-circle {
  border-radius: 50%;

  .k-color-picker-color {
    border-radius: 50%;
  }
}

@keyframes k-picker-zoom {
  0% {
    opacity: 0;
    transform: scale(0.8)
  }

  to {
    opacity: 1;
    transform: scale(1)
  }
}

.k-color-picker-enter-active {
  transform-origin: 0 0;
  animation: k-picker-zoom .2s;
}

.k-color-picker-leave-active {
  transform-origin: 0 0;
  animation: k-picker-zoom .2s reverse;
}


.k-color-picker-disabled-alpha {
  .k-color-picker-bar-box {
    justify-content: center;
  }
}